#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main()
{
	for (int i = 0; i <= 100000; i++)
	{
		int count = 0;
		int tmp = i;
		while (tmp!= 0)
		{
			count++;
			tmp/=10;
		}
		 tmp = i;
	      int sum = 0;
		while (tmp != 0)
		{
			sum+=pow(tmp%10, count);
			tmp/=10;
		}
		if (sum == i)
		{
			printf("%d\n", i);
		}
	}
	return 0;
}